from pricing_funcs import *

Spast=pd.DataFrame([100,100],index=['2021-1-5','2021-5-7'])
snow1=snowball_basic(name='testNo1',startdate='2021-1-5',enddate='2023-1-5',\
                     curdate='2021-5-1',underlying='000905.SH',Spast=Spast,\
                     r=0.095,b=0.03,knock_out_ratio=1.00,knock_in_ratio=0.75,\
                     knock_out_dates=['2021-4-6','2021-5-6','2021-6-7','2021-7-5','2021-8-5','2021-9-6','2021-10-8','2021-11-5',\
                                      '2021-12-6','2022-1-5','2022-2-7','2022-3-7','2022-4-6','2022-5-5','2022-6-6','2022-7-5','2022-8-5',\
                                      '2022-9-5','2022-10-10','2022-11-7','2022-12-5','2023-1-5'],knock_out_payoff_yearly_rates=0.16,\
                     nothing_happens_payoff_yearly_rates=0.16)

temp=snow1.pricing_snowball_basic_MC(snow1.payoff_func,Spast,snow1.K,snow1.startdate,snow1.enddate,snow1.curdate,snow1.r,snow1.b,0.16,\
                           snow1.T_year_interest,snow1.T_day_interest_noofdays_func,\
                           snow1.b,snow1.knock_out_dates,1.00,\
                           0.02,snow1.knock_in_ratio,snow1.knock_in_option_payoff,\
                           0.14,T_year_S_sim=snow1.T_year_S_sim,S_sim_class=S_sim_BS,date_series_gen_args={},S_gen_args={'freq':1,'MC_M':10000},tag3='')

print("Price of Snowball = ",temp['pricing'])
#print(np.mean(temp['pricing_detail']))
#print(np.std(temp['pricing_detail'])/np.mean(temp['pricing_detail']))

temp_greeks = snow1.greeks_basic_diff(snow1.pricing_snowball_basic_MC,Spast,snow1.K,0.1,snow1.r,snow1.b,snow1.enddate,0.01,\
                       startdate=snow1.startdate,payoff_func=snow1.payoff_func,curdate=snow1.curdate,\
                          T_year_interest=snow1.T_year_interest,T_day_interest_noofdays_func=snow1.T_day_interest_noofdays_func,\
                          mu=0.01,knock_out_dates=snow1.knock_out_dates,knock_out_ratio=snow1.knock_out_ratio,\
                          knock_out_payoff_yearly_rates=snow1.knock_out_payoff_yearly_rates,knock_in_ratio=snow1.knock_in_ratio,knock_in_option_payoff=snow1.knock_in_option_payoff,\
                          nothing_happens_payoff_yearly_rates=snow1.nothing_happens_payoff_yearly_rates,S_sim_class=S_sim_BS,\
                          T_year_S_sim=tday_year,date_series_funcs=tday_interval,date_noofdays_funcs=tday_noofdays,\
                          date_series_gen_args={},S_gen_args={'freq':1,'MC_M':10000},tag3='',requirements=['delta','gamma'])

# print()
# quickly_set_params(snow1.greeks_basic_diff,snow1)

print(temp_greeks)